package com.ugoodtech.mdcc.core.repository;

import com.ugoodtech.mdcc.core.domain.AnswerDic;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface AnswerDicRepository extends PagingAndSortingRepository<AnswerDic, Long>, QueryDslPredicateExecutor<AnswerDic> {

    @Query("select c.question.subject,a.answerOther, c.name,b.advice,b.evaluation,b.expression,a.answerPhoto from StationPaintReport a, QuestionAnswerOption c ,AnswerDic b" +
            " where a.answerId not like '%,%' and a.answerId=b.answerId and c.question.qGroup.id=:groupid and c.id=b.answerId  and a.stationReport.id=:report_id")
    List<Object[]> statPatinReport(@Param("groupid") Long groupid, @Param("report_id") Long report_id);

    @Query("from AnswerDic where advice=:advice and deleted=false and enabled=true")
    AnswerDic selectByAdvice(@Param("advice") String advice);

    @Query("from AnswerDic where evaluation=:evaluation and deleted=false and enabled=true")
    AnswerDic selectByEvaluation(@Param("evaluation") String evaluation);

    @Query("from AnswerDic where answer_id=:answer_id and deleted=false and enabled=true")
    AnswerDic selectByAnswerId(@Param("answer_id") Long answer_id);

}
